// pages/wallet_deposit/wallet_deposit.js
const $ = require('../../utils/utils');
const wallet = require("../../manager/walletManager");
var app = getApp();
const config = require('../../config');

Page({

    /**
     * 页面的初始数据
     */
    data: {
        path:""
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

        if (options.path) {
            this.setData({
                path: options.path
            });
        }

    },

    topupDeposit: function () {
        let that = this 
        console.log("#wallet_deposit(),topupDeposit()")
        wallet.topupDeposit().then(data => {
            wx.setStorageSync("deposit_flag", true)
            if (that.data.path) {
                $.goto(config.page.topupSuccess + "?path=" + that.data.path, true)
            } else {
                $.goto(config.page.topupSuccess, true)
            }

        }).catch(error => {
            $.showToast("充值失败")
        })
    },

    despoit_webview: function () {
        app.globalData.webview = {
            url: config.licenseUrl,
            title: '用户协议'
        };
        $.goto(config.page.webview);
    },
})